package com.example.serietday04;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class RegisterServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");
        req.setCharacterEncoding("utf-8");
        String userName = req.getParameter("userName");
        String userPwd = req.getParameter("userPwd");
        String email = req.getParameter("email");
        String userSex = req.getParameter("userSex");
        String userEducation = req.getParameter("userEducation");
        PrintWriter out = resp.getWriter();
        out.println("<HTML>");
        out.println("  <HEAD><TITLE>用户注册结果</TITLE></HEAD>");
        out.println("  <BODY><br/>");
        out.print("<h3>用户注册结果</h3>");
        out.println("<table border=1 align=left>");
        out.println("<tr><th>参数</th><th>参数值</th></tr>");
        out.println("<tr><td>userName</td><td>"+userName+"</td></tr>");
        out.println("<tr><td>userPwd</td><td>"+userPwd+"</td></tr>");
        out.println("<tr><td>email</td><td>"+ email +"</td></tr>");
        out.println("<tr><td>userSex</td><td>"+ userSex + "</td></tr>");
        out.println("<tr><td>userEducation</td><td>"+ userEducation +"</td></tr>");
        out.println("</table></BODY>");
        out.println("</HTML>");
        out.flush();
        out.close();
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      doPost(req,resp);
    }


}
